﻿@using MvcContrib.UI.Grid
@using XRM.Security.WebUI.Helpers
@model List<XRM.Security.WebUI.Models.IdentityCenter.IdentityCenterModel>
@{
    ViewBag.Title = "Удостоверяющие центры";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section scripts
{
    @Scripts.Render("~/bundles/gridlibrary")
}

<div>
    @{
        if (Model.Any())
        {
        Html.Grid(Model).Columns(column =>
            {
                column.For(item => Html.ActionLink(item.IdentityCenterName, "Edit", "IdentityCenter", new { id = item.Id }, null)).Named("Наименование");
                column.For(item => item.Address).Named("Адрес");
                column.For(item => item.Contact).Named("Контакты");


                if (Permission.AllowIdentityCenterEdit())
                {
                column.Custom(@<text>@Html.Partial("_GridActionsPartial", new ViewDataDictionary { { "Controller", "IdentityCenter" }, { "Id", item.Id } })</text>)
                      .Named( "<i class='fa fa-trash-o fa-action'></i>" ).Attributes( @class => "single-action" );
                }
            }).Attributes(@class => "table table-striped table-bordered", id => "table_id")
              .Render();
        }
        else
        {
            <strong>Удостоверяющие центры отсутствуют.</strong>
        }
    }
</div>

<script type="text/javascript">
    $(document).ready(function () {
        @if (Model.Any())
        {
            if (Permission.AllowIdentityCenterEdit())
            {
            <text>
            $('#table_id').dataTable({
                paging: false,
                bFilter: false,
                bSort: true,
                info: false,
                "aoColumnDefs": [
                        { 'bSortable': false, 'aTargets': [2, 3] }]
            });
            </text>
            }
            else
            {
                <text>
                $('#table_id').dataTable({
                    paging: false,
                    bFilter: false,
                    bSort: true,
                    info: false,
                    "aoColumnDefs": [
                            { 'bSortable': false, 'aTargets': [2] }]
                });
                </text>
            }
        }
        });
</script>